<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
	<head th:include="layout/templates :: head('用户管理','用户帐号管理')">
		<meta charset="utf-8" />
	</head>

   <div class="x-body layui-anim layui-anim-up">
        <form class="layui-form">
          <div class="layui-form-item">
              <label class="layui-form-label">
                  原始密码
              </label>
              <div class="layui-input-inline">
                  <input type="password" name="oldPassword" required="true" lay-verify="required"
                  autocomplete="off" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class="x-red">*</span>
              </div>
          </div>
        	<div class="layui-form-item">
              <label class="layui-form-label">
                  新密码
              </label>
              <div class="layui-input-inline">
                  <input type="password" name="newPassword" required="true" lay-verify="pass"
                  autocomplete="off" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class="x-red">*</span>6到16个字符
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">
                  确认密码
              </label>
              <div class="layui-input-inline">
                  <input type="password" name="rePassword" required="true" lay-verify="repass"
                  autocomplete="off" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class="x-red">*</span>6到16个字符
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">
              </label>
              <button  class="layui-btn" lay-filter="add" lay-submit="">
                  修改
              </button>
          </div>
      </form>
    </div>
	<script th:src="@{/assets/lib/layui/layui.all.js}" charset="utf-8"></script>
	<script type="text/javascript" th:src="@{/assets/js/xadmin.js}"></script>
	<script type="text/javascript">
	layui.form.verify({
	    pass: [/(.+){6,12}$/, '密码必须6到12位']
	  });
     //监听提交
     layui.form.on('submit(add)', function(data){
       $.ajax({
			type : "post",
			url : "./changeselfpass",
			data : data.field,
			success : function(json){
				console.info(json);
				console.info(json.status);
				if(json.success == true){
					layer.alert("修改成功", {icon: 6},function () {
						x_admin_close();
		            });
				}else{
					layer.msg(json.message);
				}
			},
			error:function(json){
				layer.msg("服务器异常，请稍后重试");
			}
		});
       
       return false;
     });
     
	function selectRole(){
		layui.layer.open({
            type: 2,
            id: 'selectRole',
            title:false,
            closeBtn :false,
            area: ['330px', '460px'],
            content: '../role/select' //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
            , btn: '取消'
            , btnAlign: 'c' //按钮居中
        });
	}
	function selectRoleReturn(data, index) {
        //关闭最后一个弹出层
        layui.layer.close(index);
        $('#roleName').val(data.roleName);
        $('#roletid').val(data.tid);
    }
	function selectGroup(){
		layui.layer.open({
            type: 2,
            id: 'selectRole',
            title:false,
            closeBtn :false,
            area: ['330px', '460px'],
            content: '../group/select' //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
            , btn: '取消'
            , btnAlign: 'c' //按钮居中
        });
	}
	function selectGroupReturn(data, index) {
        //关闭最后一个弹出层
        layui.layer.close(index);
        $('#groupName').val(data.name);
        $('#grouptid').val(data.id);
    }
	</script>
	</body>
</html>
